<?php

define('code1', '
<form name="[%$form.formcode%]" id="[%$form.formcode%]" method="post" action="[%$form.action%]">
	<input type="hidden" name="linkurl" value="add">
	<input type="hidden" name="fgid" id="fgid" value="[%$form.fgid%]">
	<input type="hidden" name="formcode" id="formcode" value="[%$form.formcode%]">
	<input type="hidden" name="countattrs" id="countattrs" value="[%$form.countattrs%]">
	<input type="hidden" name="isseccode" id="isseccode" value="[%$form.isseccode%]">
	<div class="tg">[%$form.formgroupname%]</div>
	<div class="f">
		<table style="width: 100%" class="formlist">
			<tr>
				<td colspan="2" class="content">[%$form.content%]</td>
			</tr>
			[%forlist from=$attr key=i%]
			[%if $attr[i].isline==1%]
			<tr>
				<td colspan="2" class="content">[%$attr[i].typename%]</td>
			</tr>
			[%else%]
			<tr>
				<th>[%$attr[i].typename%]</th>
				<td>
					[%if $attr[i].inputtype==\'string\'%]<input type="text"[%if $attr[i].isvalidate==1%] onblur="if (this.value.match(/^[%$attr[i].validatetext%]$/ig)==null){alert(\'[%$attr[i].typename%][%$lngpack.inputerr%]\');return false;}" [%/if%]name="formatt[[%$attr[i].attrname%]]" size="[%$attr[i].attrsize%]" maxlength="[%$attr[i].attrlenther%]" value="[%$attr[i].attrvalue%]" class="infoInput"/>[%/if%]
					[%if $attr[i].inputtype==\'int\'%]<input type="text" [%if $attr[i].isvalidate==1%] onblur="if (this.value.match(/^[%$attr[i].validatetext%]$/ig)==null){alert(\'[%$attr[i].typename%][%$lngpack.inputerr%]\');return false;}" [%/if%]name="formatt[[%$attr[i].attrname%]]" size="[%$attr[i].attrsize%]" maxlength="[%$attr[i].attrlenther%]" value="[%$attr[i].attrvalue%]" class="infoInput"/>[%/if%]
					[%if $attr[i].inputtype==\'datetime\'%]
						 <input type="text" name="formatt[[%$attr[i].attrname%]]" size="[%$attr[i].attrsize%]" value="[%$attr[i].attrvalue%]" class="infoInput"/>
					[%/if%]
					[%if $attr[i].inputtype==\'img\'%]
						<input type="text" name="formatt[[%$attr[i].attrname%]]" size="[%$attr[i].attrsize%]" value="[%$attr[i].attrvalue%]" class="infoInput"/>
					[%/if%]
					[%if $attr[i].inputtype==\'addon\'%]
						<input type="text" name="formatt[[%$attr[i].attrname%]]" size="[%$attr[i].attrsize%]" value="[%$attr[i].attrvalue%]" class="infoInput"/>
					[%/if%]
					[%if $attr[i].inputtype==\'text\'%]<textarea name="formatt[[%$attr[i].attrname%]]" cols="[%$attr[i].attrsize%]" rows="[%$attr[i].attrrow%]" class="infoInput">[%$attr[i].attrvalue%]</textarea>[%/if%]
					[%if $attr[i].inputtype==\'select\'%]
						<select size="1" name="formatt[[%$attr[i].attrname%]]">
						[%forlist from=$attr[i].attrvalue key=ii%]
							<option [%if $attr[i].attrvalue[ii].selected==\'selected\'%]selected="selected" [%/if%]value="[%$attr[i].attrvalue[ii].name%]">[%$attr[i].attrvalue[ii].name%]</option>
						[%/forlist%]
						</select>
					[%/if%]
					[%if $attr[i].inputtype==\'radio\'%]
						[%forlist from=$attr[i].attrvalue key=ii%]
							<input [%if $attr[i].attrvalue[ii].selected==\'selected\'%]checked="checked" [%/if%]name="formatt[[%$attr[i].attrname%]]" type="radio" value="[%$attr[i].attrvalue[ii].name%]" /> [%$attr[i].attrvalue[ii].name%]
						[%/forlist%]
					[%/if%]
					[%if $attr[i].inputtype==\'checkbox\'%]
						[%forlist from=$attr[i].attrvalue key=ii%]
							<input [%if $attr[i].attrvalue[ii].selected==\'selected\'%]checked="checked" [%/if%]name="formatt[[%$attr[i].attrname%]]" type="checkbox" value="[%$attr[i].attrvalue[ii].name%]" /> [%$attr[i].attrvalue[ii].name%]
						[%/forlist%]
					[%/if%]
					[%if $attr[i].attrcue!=\'\'%]<span>[%$attr[i].attrcue%]</span>[%/if%]
				</td>
			</tr>
			[%/if%]
			[%/forlist%]
			[%if $form.isseccode==1%]
			<tr>
				<th>[%$lngpack.verification%]</th>
				<td>
					<input type="text" id="code" name="seccode" class="infoInput" maxlength="4" size="3" style="text-transform: uppercase;"/>
					<img title="验证码" id="[%$form.formcode%]seccodesrc" onclick="sessionimg(\'[%$form.formcode%]seccodesrc\',\'[%$url%]\')" src="[%$seccodelink%]" style="cursor: pointer;" align="absmiddle"/>
				</td>
			</tr>
			[%/if%]
			<tr>
				<td></td>
				<td>
					<input type="submit" id="[%$form.formcode%]botton" name="Submit" value="[%$lngpack.submitbotton%]" class="buttonface" />
				</td>
			</tr>
		</table>
	</div>
</form>
');

define('code2', '[%beark name=form filename=$filename class=$lng,$read.fgid%]');
if (isset($modulesid) && $modulesid == TRUE) {
	$i = isset($modules) ? count($modules) : 0;
	$modules[$i]['plugname'] = '内容关联表单输出';

	$modules[$i]['code'] = basename(__FILE__, '.php');
	$modules[$i]['desc'] = '用于在内容阅读页下面增加表单，以实现咨询等功能！<a class="infolink05" target="_blank" href="http://www.ecisp.cn/chm/k18.html">点击参考标签说明</a>';
	$modules[$i]['lng'] = '0';
	$modules[$i]['mid'] = '0';
	$modules[$i]['sid'] = '0';
	$modules[$i]['tid'] = '0';
	$modules[$i]['dlid'] = '0';

	$modules[$i]['btid'] = '0';

	$modules[$i]['blid'] = '0';

	$modules[$i]['config'] = array(
	    array('botname' => '标签类型', 'name' => 'codetype', 'type' => 'select', 'value' => '0', 'str' => '如选择列表，请修改相应的Lib文件夹模板',
		'sevalue' => array(0 => '调用模板片段（适用于页面的调用）', 1 => '表单显示片段代码')),
	    array('botname' => '自定模板文件名', 'name' => 'filename', 'type' => 'text', 'value' => '', 'str' => '可选项，仅填写lib文件夹中的文件名，如为空默认为：form'),
	);
	return;
}

class form {









	function get_code($lng, $mid, $tid, $sid, $dlid, $newArray=array(), $otherarray=array()) {
		if ($newArray[0]['codetype'] == 0) {
			$str = code2;

			if (!empty($newArray[1]['filename'])) {
				$str = str_replace(' filename=$filename', ' filename=' . $newArray[1]['filename'], $str);
			} else {
				$str = str_replace(' filename=$filename', '', $str);
			}
			if (!empty($newArray[2]['m2'])) {
				$str = str_replace('$1', $newArray[2]['m2'], $str);
			} else {
				$str = str_replace('$1', 0, $str);
			}
			if (!empty($otherarray['btid'])) {
				$str = str_replace('$2', $otherarray['btid'], $str);
			} else {
				$str = str_replace('$2', 0, $str);
			}
			if (!empty($otherarray['blid'])) {
				$str = str_replace('$3', $otherarray['blid'], $str);
			} else {
				$str = str_replace('$3', 0, $str);
			}
			if (!empty($newArray[3]['hit'])) {
				$str = str_replace('$4', $newArray[3]['hit'], $str);
			} else {
				$str = str_replace('$4', 0, $str);
			}
			if (!empty($newArray[4]['m6'])) {
				$str = str_replace('$5', 'h', $str);
			} else {
				$str = str_replace('$5', 0, $str);
			}
			if (!empty($newArray[5]['m7'])) {
				$str = str_replace('$6', $newArray[5]['m7'], $str);
			} else {
				$str = str_replace('$6', 0, $str);
			}
			if (!empty($newArray[6]['m8'])) {
				$str = str_replace('$7', $newArray[6]['m8'], $str);
			} else {
				$str = str_replace(',$7', '', $str);
			}
		} else if ($newArray[0]['codetype'] == 1) {
			$str = code1;
		}
		return $str;
	}

}
?>